import json

with open('./train.json','w+',encoding='utf-8') as outfile:
    outfile.write('[')
    with open("./news2016zh_valid.json",encoding="utf-8") as f:
        line1 = f.readline()
        js1 = json.loads(line1)
        outfile.write(f"\"{js1['content']}\"")
        while True:
            line = f.readline()
            line.replace('\\','')
            if not line:
                break
            try:
                js = json.loads(line)
            except:
                continue

            js = js['content']
            if len(js) == 0 :
                continue
            outfile.write(f",\"{js}\"")
    outfile.write(']')
